package heiing.collection.diff;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import lombok.Getter;

/**
 *
 * @author heiing
 * @param <T>
 */
@Getter
public class CollectionDiffResult<T> {

    private Collection<T> newItems;
    private Collection<T> removedItems;
    private Map<T, T> changedItems;

    public CollectionDiffResult() {
        this(null, null);
    }

    public CollectionDiffResult(Collection<T> adds, Collection<T> removed) {
        this(adds, removed, null);
    }

    public CollectionDiffResult(Collection<T> adds, Collection<T> removed, Map<T, T> changed) {
        this.setNewItems(adds);
        this.setRemovedItems(removed);
        this.setChangedItems(changed);
    }

    public final CollectionDiffResult<T> setNewItems(Collection<T> items) {
        this.newItems = null == items ? Collections.emptySet() : items;
        return this;
    }

    public final CollectionDiffResult<T> setRemovedItems(Collection<T> items) {
        this.removedItems = null == items ? Collections.emptySet() : items;
        return this;
    }

    public final CollectionDiffResult<T> setChangedItems(Map<T, T> items) {
        this.changedItems = null == items ? Collections.emptyMap() : items;
        return this;
    }

}
